export const vertexShader = /*glsl*/`
attribute vec3 a_position;
attribute vec3 a_color;
attribute vec3 a_normal;
varying vec3 v_color;

//法向量
varying vec3 v_normal;


//模型矩阵
uniform mat4 u_modelMatrix;
//视图矩阵
uniform mat4 u_viewMatrix;
//投影矩阵
uniform mat4 u_projectionMatrix;
void main() {
  v_color = a_color;
  v_normal = (u_modelMatrix * vec4(a_normal, 1.0)).xyz;
  gl_Position = u_projectionMatrix*u_viewMatrix*u_modelMatrix*vec4( a_position, 1.0 );
}
`


export const fragmentShader = /*glsl*/`
precision mediump float;
varying vec3 v_color;
varying vec3 v_normal;
//方向光
uniform vec3 u_lightDirection;
uniform vec3 u_lightColor;
void main() {
  vec3 normal1=  normalize(v_normal);
  vec3 normal2=  normalize(u_lightDirection);
  float light = max(dot(normal1, normal2), 0.0);
  vec4 diffuseColor = vec4(light * u_lightColor, 1.0);
  gl_FragColor = vec4(v_color, 1.0)*0.2+diffuseColor;
}
`